

obj-y += kify-dis-builtin.o

KIFY_DIS_HOME := $(PWD)
# KIFY_DIS_HOME := $(SRC_DIR)/disas/kify-dis
OPCODE_HOME := $(KIFY_DIS_HOME)/binutils.o
OPCODE_LDFLAGS := -L$(OPCODE_HOME)/lib64 -L$(OPCODE_HOME)/lib -lopcodes -lbfd  -lz -liberty
CFLAGS += -I$(OPCODE_HOME)/include -std=gnu99 -Werror -fPIC
LDFLAGS += -ldl

run: disas-aarch64
	./disas-aarch64 0x0
	
disas-aarch64: disas-aarch64.o kify-dis-builtin.o
	$(CC) $^ $(LDFLAGS) -o $@

kify-dis-builtin.o: 
	$(MAKE) -e -C $(KIFY_DIS_HOME) binutils.o
	$(MAKE) -e -C $(KIFY_DIS_HOME) kifydisassembler.o
	$(LD) -r -o $@ kifydisassembler.o $(OPCODE_LDFLAGS)

binutils.o:
	./build_binutils.sh

clean:
	rm *.o disas-aarch64